<template>
	<view
		:style="'order:'+item.order+';'+item.css"
		class="box-swiper-list-post">
		<scroll-view scroll-x>
			<view
				class="_for"
				v-for="item in list"
				@click="$_to('post/detail?pid=' + item.pid)">
				<text class="iconfont icon-yinyong"></text>
				<view class="_title">{{item.title?item.title:$_filterHtml(item.content)}}</view>
				<view class="_user">
					<view class="_user-box">
						<view class="_user-avatar">
							<image :src="item.author.avatar" mode="widthFix"></image>
						</view>
						<view class="_user-nickname">{{item.author.nickname}}</view>
					</view>
				</view>
			</view>
			
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name:"box-swiper-list-post",
		props:{
			item:{
				type:Object,
				default:null
			}
		},
		data() {
			return {
				list:[],
				listStatus:"loading",
			};
		},
		mounted(){
			this.getList();
		},
		methods: {
			getList(){
				this.$_request(
					"GET", "/api/fresns/v1/post/list",
					{
						...this.item.query,
						"filterType":"whitelist",
						"filterKeys":"pid,title,content,author.avatar,author.nickname",
						"page":1
					},
					(res) => {
						if (res.data.data.list.length) {
							this.list = res.data.data.list;
							this.listStatus = "success";
						} else {
							this.listStatus = "empty";
						}
					}
				)
			}
		}
	}
</script>

<style lang="scss" scoped>
.box-swiper-list-post{
	padding: 25rpx;
	background: #FFF;
	scroll-view{
		white-space: nowrap;
		._for{
			display: inline-flex;
			flex-flow: column;
			background: $background;
			margin: 0 25rpx 0 0;
			border-radius: 10rpx;
			padding: 25rpx;
			width: 250rpx;
			height: 300rpx;
			.iconfont{
				display: flex;
				align-items: center;
				font-size: 80rpx;
				line-height: 80rpx;
				color: $placeholder;
				opacity: .5;
			}
			._title{
				font-size: 32rpx;
				line-height: 45rpx;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 3;
				overflow: hidden;
				margin-top: 15rpx;
			}
			._user{
				flex: 1;
				display: flex;
				align-items: flex-end;
				._user-box{
					display: flex;
					align-items: center;
					._user-avatar{
						width: 30rpx;
						height: 30rpx;
						overflow: hidden;
						border-radius: 100rpx;
						margin-right: 10rpx;
					}
					._user-nickname{
						color: $placeholder;
						font-size: 22rpx;
						line-height: 22rpx;
					}
				}
			}
		}
	}
}
</style>